<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib prefix="bean" uri="http://struts.apache.org/tags-bean"%>
<%@taglib prefix="logic" uri="http://struts.apache.org/tags-logic"%>
<%@taglib prefix="html" uri="http://struts.apache.org/tags-html"%>
<jsp:useBean id="productBean" class="by.grsu.bso.beans.ProductUtilBean"
	scope="application" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">


<logic:notPresent name="user" scope="session">
	<logic:redirect href="../createUser.do"></logic:redirect>
</logic:notPresent>

<logic:present name="user" scope="session">
	<head>
		<link rel="stylesheet" type="text/css" href="CSS/product.css" />
		<title>О товаре</title>
	</head>
	
	<body>
	<div class="main">
	<c:set var="currentProduct" value="${applicationScope.productBean.getProduct(param.product)}" />
		<div class="divOne">
			<img style="padding-right: 10px;" src="${currentProduct.imageBase64}"
				align="left">
			<p>Категория: </p>
			<p>Название: ${currentProduct.name}</p>
			<p>Год издания: ${currentProduct.yearPublication}</p>
			<p>Автор: ${currentProduct.autor}</p>
			<p>Цена: ${currentProduct.price} руб.</p>
			<p>Кол. стр.: ${currentProduct.quantityPages}</p>
				
			<div style="padding-top: 35px;" >
			<p>Описание: ${currentProduct.discription}</p>
			</div>	
				
		</div>
		
		<div class="divTwo">
		
		<c:choose>
		
			<c:when test="${currentProduct.isAvailable == false}">
				<html:form action="/pages/put_product">
					<html:hidden property="productId" value="${currentProduct.id}"/>
					<input type="submit" class="button-submit" value="Положить в корзину"/>
				</html:form>
			</c:when>
			
			<c:otherwise>
				<h4 style="color: red">Товара нет в наличии!</h4>
			</c:otherwise>
			
		</c:choose>
				
		</div>
		
	</div>	
		
	</body>

	</html>

</logic:present>
